import { request } from '../utils/request'

// 添加新的评论
export function addOrderDiscuss(params) {
    return request({
        method: 'post',
        url: '/orderDiscuss/',
        data: params,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}
export function getOrderDiscussList(id) {
    return request({
        method: 'get',
        url: `/orderDiscuss/${id}`,
        data: null,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}


// 根据ID获取评论
// export function getOrderDiscussById(id) {
//     return request({
//         method: 'get',
//         url: `/orderDiscuss/${id}`,
//     })
// }

// 更新评论信息
export function updateOrderDiscuss(params) {
    return request({
        method: 'put',
        url: '/orderDiscuss/',
        data: params,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

// 删除评论
export function deleteOrderDiscuss(id) {
    return request({
        method: 'delete',
        url: `/orderDiscuss/${id}`,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

// 根据用户名获取评论回复
export function getDiscussRepliesByUsername(userName) {
    return request({
        method: 'get',
        url: `/orderDiscuss/user/${userName}`,
    })
}

// 根据回复ID获取评论回复
export function getDiscussRepliesByReplyId(replyId) {
    return request({
        method: 'get',
        url: `/orderDiscuss/reply/${replyId}`,
    })
}

// 根据ID获取评论及其回复
export function getOrderDiscussWithRepliesById(id) {
    return request({
        method: 'get',
        url: `/orderDiscuss/aaa/${id}`,
    })
}

// 获取用户点赞的评论ID列表
export function getUserLikeList() {
    return request({
        method: 'get',
        url: '/orderDiscuss/userLike',
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

// 点赞
export function addLike(id) {
    return request({
        method: 'post',
        url: `/addLike/${id}`,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

// 取消点赞
export function deleteLike(id) {
    return request({
        method: 'delete',
        url: `/deleteLike/${id}`,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}